package demo1;

import java.util.Scanner;

public class Stringdemo2 {
    public static void main(String[] args) {
        String str = "zhangsan";
        String str2 = "123456" ;

        for (int i = 0; i < 3; i++) {
            Scanner sc = new Scanner(System.in);
            System.out.println("请输入用户名");
            String username = sc.next();
            //Scanner sc2 = new Scanner(System.in);
            System.out.println("请输入密码");
            String password = sc.next();
            if (username.equals(str) && password.equals(str2)) {
                System.out.println("用户登录成功");
                break;
            }else{
                if (i==2) {
                    System.out.println("用户登录失败," + "账号已被锁定");
                }else{
                    System.out.println("用户登录失败," + "还剩下" + (2 - i) + "次机会");
                }
            }
        }


    }
}
